import datetime

from app import db


# 得到db
# 这个py是为了其他py调用这个py，从而得到数据库模型
# 其他py调用后就可以直接写语句操作数据库了，不用再声明表内容了

# 因为用了flask_sqlalchemy，所以不用再导入flask.session,flask.Column什么的了
# 直接在这些前面加上db即可
class order(db.Model):
    __tablename__ = 'order'
    id = db.Column(db.Integer, primary_key=True)
    order_id = db.Column(db.String(50), nullable=False)
    open_id = db.Column(db.String(255), nullable=False)
    order_str = db.Column(db.String(5000), nullable=False)
    order_status = db.Column(db.String(255), nullable=False)


class videos(db.Model):
    # 对应MySQL中数据表的名字
    __tablename__ = 'videos'

    # 创建字段
    id = db.Column(db.Integer, primary_key=True)
    video_name = db.Column(db.String(255), nullable=False)
    video_price = db.Column(db.Float, nullable=False)
    video_sort = db.Column(db.String(255), nullable=False, default='默认分类')
    video_duration = db.Column(db.Time, default=None)
    is_delete = db.Column(db.Enum('no', 'yes'), nullable=False, default='no')
    upload_data = db.Column(db.Date, default=datetime.datetime.now)
    url = db.Column(db.String(1000), nullable=False)
    fildID = db.Column(db.String(100))
    is_recommend = db.Column(db.Enum('yes', 'no'), nullable=False, default='no')


class site_user(db.Model):
    # 对应MySQL中数据表的名字
    __tablename__ = 'site_user'

    # 创建字段
    id = db.Column(db.Integer, primary_key=True)
    open_id = db.Column(db.String(255), nullable=False)
    is_admin = db.Column(db.Enum('no', 'yes'), nullable=False, default='no')

    promission = db.Column(db.String(6000), default=None)
    user_id = db.Column(db.String(255))
    user_profilephoto_url = db.Column(db.String(1000))
    shopping_cart = db.Column(db.String(5000))

# class site_user(db.Model):
#     __tablename__ = 'site_user'
#     user_id = db.Column(db.Integer, primary_key=True, nullable=False)
#     account = db.Column(db.String(255), nullable=False)
#     password = db.Column(db.String(255), nullable=False)
#     admin = db.Column(db.Enum('yes', 'no', default='no'))
#     email = db.Column(db.String(255), nullable=False)
#     email_bind = db.Column(db.Enum('yes', 'no'), nullable=False)
#     email_hash = db.Column(db.String(255))
